package com.zytlifeservice;

import com.zytlifeservice.properties.StorageProperties;
import com.zytlifeservice.service.FileUploadService;
import com.zytlifeservice.service.pay.PublicService;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;

@EnableConfigurationProperties(value = StorageProperties.class)
@EnableScheduling
@ServletComponentScan
@SpringBootApplication
public class ZytlifeserviceApplication extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(ZytlifeserviceApplication.class);
    }

    public static void main(String[] args) {
        SpringApplication.run(ZytlifeserviceApplication.class, args);
    }

    @Bean
    CommandLineRunner init(FileUploadService service) {
        return (args) -> {
            service.init();
        };
    }

    @Bean
    CommandLineRunner initBMMsg(PublicService service) {
        return (args) -> {
            service.initBMMsg();
        };
    }
}
